feat: Add optional jwt_issuer option for session token validation - #725
feat: Add optional jwt_issuer option for session token validation#725m0tzy wants to merge 2 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
Original prompt from madison.packer
|
Greptile SummaryAdds optional issuer validation for session access tokens while preserving existing behavior when no issuer is configured.
Confidence Score: 5/5The PR appears safe to merge; issuer validation is consistently applied and the previously missing refresh coverage has been added. No actionable new failures or repository-rule violations remain. The previous refresh-testing finding is fully addressed with matching and mismatched issuer tests for both synchronous and asynchronous refresh paths. Important Files Changed
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
Adds an opt-in
issclaim check toSession/AsyncSessionaccess-token validation (both theauthenticate()andrefresh()jwt.decodecalls). Whenjwt_issueris configured on the client it is passed to PyJWT; when unset, behavior is unchanged (noisscheck — PyJWT skips_validate_isswhenissuer is None).jwt_issueraccepts a single issuer or a list so an app can accept tokens from more than one issuer (e.g. during an issuer migration); PyJWT'sissuerparameter already acceptsstr | Container[str]. AWORKOS_ISSUERenv value is split on commas (trimmed, empties dropped; a single value stays astr). Namedjwt_issuerto sit alongside the existingjwt_leewayoption.Only hand-maintained (
@oagen-ignore-file) files are touched:_base_client.py,session.py.Opt-in rather than defaulted because the API does not mint a single issuer shape — it varies by environment (
https://api.workos.comfor legacy environments,https://api.workos.com/user_management/<clientId>for environments created since mid-2025, custom auth domains, and flag-gated path variants). Mirrors workos/workos-node#1694.Link to Devin session: https://app.devin.ai/sessions/0ee38e859a9849658a7cdb2d215d89a6
Open in Devin Desktop: https://app.devin.ai/desktop/session/0ee38e859a9849658a7cdb2d215d89a6?variant=devin
Requested by: @m0tzy